package com.zt.springcloud.service.Impl;

import cloud.zt.springboot.utils.TokenUtils;
import com.zt.springcloud.RemoteProductService;
import com.zt.springcloud.RemoteUserService;
import com.zt.springcloud.entity.Cart;
import com.zt.springcloud.entity.Vo.CartVo;
import com.zt.springcloud.service.ShopCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author RedReins
 * @version 1.0
 * @description: TODO
 * @date 2021/9/19 11:11
 */

@Service
public class ShopCartServiceImpl implements ShopCartService {
    @Autowired
    private RemoteProductService remoteProductService;
    @Autowired
    private RemoteUserService remoteUserService;
    @Override
    public Boolean insertCart(Cart cart) {
        return remoteProductService.addShopCart(cart);
    }

    @Override
    public List<CartVo> getCartList() {
        Long id = remoteUserService.getUserInfo(TokenUtils.getUsername()).getId();
        return remoteProductService.getCartList(id);
    }

    @Override
    public Integer addShopCartAmount(Long itemid) {
        return remoteProductService.addShopCartAmount(itemid);
    }

    @Override
    public Integer minusShopCartAmount(Long itemid) {
        return remoteProductService.minusShopCartAmount(itemid);
    }

    @Override
    public List<CartVo> findItemsByIds(String itemIds) {
        return remoteProductService.findItemsByIds(itemIds);
    }
}
